<template>
	<view>
		<view style="text-align: center;font-size: 32rpx;font-weight: bold;height: 80rpx;line-height: 80rpx;">
			好评率：{{favorableRate}}%
		</view>
		<view class="evaluate-box">
			<view :class="{'active-view':evaluateType==item.type}" v-for="(item, index) in evaluateList" @click="evaluateType=item.type">
				{{item.name}}
			</view>
		</view>
		<scroll-view scroll-y="true" style="height: calc(100vh - 170rpx);">
			<view class="card" v-for="item in list">
				<view class="score">
					<view class="">
						评分：<u-rate :count="5" readonly  :value="item.scoreNumber"></u-rate>
					</view>
				</view> 
				<view class="remark">
					{{item.desc}}
				</view>
				<view class="media-box">
					<image :src="$imageUrl(imgItem)" @click="$util.enlargement(item.img,imgIndex)" v-for="(imgItem, imgIndex) in item.img" mode=""></image>		
				</view>
				<view class="time">
					{{item.createTime}}
				</view>
				<view style="display: flex;justify-content: space-between;margin-bottom: 30rpx;">
					<view style="font-size: 28rpx;color: #333333;font-weight: bold;">
						{{item.driverTypeName}}
					</view>
					<view style="font-size: 24rpx;color: #666666;font-weight: bold;">
						上门时间:2023/05/05 14:00
					</view>
				</view>
				<view class="location-box">
					<image src="/static/send-ico.png" mode=""></image>
					{{item.startLocation}}
				</view>
				<view class="location-line">
			
				</view>
				<view class="location-box">
					<image src="/static/receive-ico.png" mode=""></image>
					{{item.endLocation}}
				</view>
			</view>
			<u-empty
			v-if="list.length==0"
			marginTop="80rpx"
			        text="暂无评价"
			        icon="http://cdn.uviewui.com/uview/empty/message.png"
			>
			</u-empty>
		</scroll-view>
		
		<Loading/>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				evaluateList:[],
				evaluateType:'',
				favorableRate:''
			}
		},
		watch:{
			evaluateType(){
				this.getEvaluate()
			}
		},
		onShow() {
			this.getEvaluate()
		},
		methods: {
			getEvaluate(){
				let requestData={
					driverId:uni.getStorageSync("userData").id,
					page:1,
					size:100,
					type:this.evaluateType
				}
				this.$myRequest('/api/driver/mine/v1/evaluate',requestData).then(res => {
					let data = res.data
					this.favorableRate=data.favorableRate
					this.evaluateList = [{
						name: '全部',
						type:''
					}, {
						name: `图片(${data.imagesNum})`,
						type:1
					}, {
						name: `好评(${data.goodReputationNum})`,
						type:2
					}, {
						name: `中/差评(${data.negativeCommentNum})`,
						type:3
					}]
					let list=res.data.pageResult.data||[]
					list.forEach(item=>{
						item.img=item.images?item.images.split(','):[]
					})
					this.list=list
				})
			}
		}
	}
</script>

<style lang="scss">
	.card {
		background-color: #ffffff;
		padding: 20rpx;
		margin: 20rpx 0;
		border-radius: 20rpx;
		position: relative;
		}
		.evaluate-box {
			display: flex;
			justify-content: space-between;
			padding: 20rpx;
		
			>view {
				padding: 5rpx 32rpx;
				font-size: 28rpx;
				color: #333333;
				font-weight: bold;
				text-align: center;
				border-radius: 8rpx;
				border: 2rpx solid #ffffff;
			}
		
			.active-view {
				color: $theme-color;
				border: 2rpx solid $theme-color;
			}
		}
		
	.location-box {
		display: flex;
		align-items: center;
		font-size: 24rpx;
		color: #999999;
	
		image {
			width: 40rpx;
			height: 40rpx;
			margin-right: 22rpx;
		}
	}
	
	.location-line {
		width: 2rpx;
		height: 42rpx;
		background: #CBCBCB;
		margin: 10rpx 19rpx;
	}
	
	.score {
		display: flex;
		font-size: 28rpx;
		color: #333333;
		font-weight: bold;
		padding: 0 0 20rpx 0;
		align-items: center;
		justify-content: space-between;
	}
	
	.remark {
		font-size: 28rpx;
		color: #333333;
		font-weight: bold;
		padding-bottom: 34rpx;
	}
	
	.time {
		text-align: right;
		font-size: 24rpx;
		color: #666666;
		border-bottom: 2rpx solid #E6E6E6;
		margin-bottom: 24rpx;
		padding-bottom: 24rpx;
	}
	.media-box {
		display: flex;
		flex-wrap: wrap;
	
		>image{
			width: 238rpx;
			height: 238rpx;
			border-radius: 12rpx;
			margin-right: 20rpx;
			margin-bottom: 20rpx;
			overflow: hidden;
		}
	}
</style>
